Copyright: Copyright (c) Phil Allen 1994


Peacock Contents
PEACOCK

The Color By Name system for Microsoft Windows

PEACOCK is a color by name system which allows you to create applications which can have their colors configured by symbolic name rather than by RGB values.

PEACOCK comes with a predefined database of names and RGB values. Literally Hundreds or predefined color names! Peacock also allows users to add color names.  In this way the color database can be extended by the user.

PEACOCK Benefits

PEACOCK .INI Database

PEACOCK VB Interface to VBX

PEACOCK DLL Interface

PEACOCK VB Interface to DLL

PEACOCK Installation

PEACOCK Registration


PEACOCK Benefits

Whats so great about PEACOCK?  Let us explain the benifits.

First users and programmers can think about colors they way normal people think about colors.  By Name!  If you want something to be skyblue you simple tell PEACOCK that that is the color you want.  PEACOCK will determine the RGB values for the color.  Since PEACOCKs color name database is huge there will be very few color names that it does not know of. If you happen upon a color name that PEACOCK does not already know you can simple extend the PEACOCK database to include the color.

Secondly, using PEACOCK can help applications look identical on systems that have a wide variance in monitors.  A user PEACOCK database can be tweeked for a given system.  This can overcome problems which can not be overcome by using RGB values. For instance if skyblue is 0x000455 on one system and 0x000466 on another system by tweeking the PEACOCK database to those values you can have the applications look identical on both systems.  Once the database is tweeked all applications that use PEACOCK on both systems will look the same without the user having to tweek the .INI files for the application, or configure the application manually.

Third,  PEACOCK gives you a chance to give your user something special.  using PEACOCK allows all your applications to be more configurable.  Let the user choose color by name and save the name.  Now the .INI file for your application has meaningful data in it.  Something the user can relate to.


Peacock .INI Database
PEACOCK Color Name Database

The PEACOCK color name database is stored in a .INI file as ascii text.  The user can update this text or more use an interactive editor to update the values in the PEACOCK database. This allows systems to be configured by each users so that the colors look right!

Sections of the .INI file.

The [rgbcolors] section contains all the predefined colors in the PEACOCK database.  There are a ton of them.  They are defined with and without spaces.  This allows the user to enter them either way.

A special note of thanks is due the MIT/X crew that first put together the rgb database for the X Window system.  PEACOCK uses their work and is happy to do so!

The [usercolors] section is where user defined color names are placed.  This allows users to not only tweek the database for existing colors but to extend it with there own colors such as
yikesred
or
wowblue

The format of each line in the PEACOCK color name datbase has the following format
ColorName = Value
Where ColorName is the ascii name of the color and value is the RGB value of the color.  The value is stored as a integer in hexidecimal format.


PEACOCK Custom Control (VBX) Interface

Properties                              Examples

The Peacock Custom Control provides properties which allow access to the Peacock color name database.  The database is accesed by the properties and by setting the Action property to the proper value.


ColorName 	ColorValue

DefaultValue 	Action

ColorList 	ColorListCnt

UserColorList 	UserColorListCnt


ColorName Property

The ColorName property is set by the user of the PEACOCK Custom Control.  It must contain the name of the color which you wish to get the RBG values for.


ColorValue Property

The ColorValue property contains the Windows RGB color value stored in a long integer.  This property is read back after an attempt to find a color name in the database is made. If the addition or change of a user color name is attempted this value is written to and used for the added/changed RBG value.


DefaultValue Property

The DefaultValue property is used to hold the RGB color value which should be used returned if an attempt to find a color name in the database fails.


Action Property

There are a number of actions available while using PEACOCK. They are listed and described below.

The ACTION property can take on the following values
0 - ACTION_NONE
1 - ACTION_GET_COLOR
2 - ACTION_GET_PREDEF_COLOR
3 - ACTION_GET_USER_COLOR
4 - ACTION_ADD_COLOR
5 - ACTION_DELETE_COLOR
6 - ACTION_CHECK_COLOR
7 - ACTION_CHECK_PREDEF_COLOR
8 - ACTION_CHECK_USER_COLOR

ACTION_NONE is the default value.  It is also the value which the Action property is set to after every sucessful operation. If you attempt to perform a ACTION_GET_COLOR, after the call you can check the Action property.  If it now is equal to ACTION_NONE the operation was a success.  If it is still equal to ACTION_GET_COLOR then there has been an error.

ACTION_GET_COLOR attempts to return the RGB value for a color name from the database.  The sequence to use this action would be something like

Peacock1.Action = ACTION_GET_COLOR
if Peacock1.Action <> ACTION_NONE then
' Some error handling
else
Form1.BackColor = Peacock1.ColorValue
end if

This action looks in both the [rgbcolors] predefined color name database, but also the [usercolors] portion of the database.

ACTION_GET_PREDEF_COLOR attempts to return the RGB value for a color name from the database.  It works just like ACTION_GET_COLOR except it only searches the [rgbcolors] predefined section of the database.

ACTION_GET_USER_COLOR attempts to return the RGB value for a color name from the database.  It works just like ACTION_GET_COLOR except it only searches the [usercolors] user section of the database.

ACTION_ADD_COLOR attempts to add a ColorName to the user portion of the ColorName database.

ACTION_DELETE_COLOR attempts to remove a ColorName from the user portion of the ColorName database.

ACTION_CHECK_COLOR will check for the existance of a ColorName in the database.  If the color exists the Action property will be set to ACTION_NONE upon return from the call.  If the ColorName does not exist the Action Property will still contain ACTION_CHECK_COLOR.  This action searches both the [rgbcolors] predefined section of the database and [usercolors] the user defined portion of the database.

ACTION_CHECK_PREDEF_COLOR works just like ACTION_CHECK_COLOR with the exception that it only checks the [rgbcolors] predefined section of the database.

ACTION_CHECK_USER_COLOR works just like ACTION_CHECK_COLOR with the exception that it only checks the [usercolors] user section of the database.


ColorList Property

The ColorList property is an array property which contains a list of all the ColorNames which are in the predefined [rgbcolors] section of the database.  It is initialized at start up.


ColorListCnt Property

The ColorListCnt property contains a count of the number of ColorNames that will be found in the COLOR_LIST array of ColorNames.


UserColorList Property

The ColorList property is an array property which contains a list of all the ColorNames which are in the user [usercolors] section of the database.  It is initialized at start up.


UserColorListCnt Property

The UserColorListCnt property contains a count of the number of ColorNames that will be found in the USER_COLOR_LIST array of ColorNames.


Take a look at SAMPLVBX.FRM for source code examples of how to use the PEACOCK Custom Control to process color by name requests.


Peacock DLL Interface
PEACOCK Dynamic Link Library Interface.

This section talks about the DLL interface library to Peacock.

The following functions are provided by Peacock. For the curious it can be noted that the cbn stands for "Color By Name".

PEACOCK provides the following functions in the PEACOCK.DLL Library.  These can be used from any windows programming environment which supports DLLs.

cbnAddUserColor()

cbnDeleteUserColor()

cbnColorExists()

cbnListColors()

cbnGetColor()

cbnGetUserColor()

cbnGetColorList()

cbnGetUserColorList()


cbnAddUserColor

Also see

VOID cbnAddUserColor(LPSTR colorName,long colorValue)

Parameters:
 LPSTR colorName : This is the name of the color to add.
long  colorValue : This is the RGB value of the color.

Description:
 To add a color to the [usercolors] section of the PEACOCK color name database you make this call.

Returns:
 Nothing


Also See the Following

cbnDeleteUserColor()


cbnDeleteUserColor

Also see

VOID cbnDeleteUserColor(LPSTR colorName)

Parameters:
 LPSTR colorName : This is the name of the color to delete.

Description:
 To delete a color to the [usercolors] section of the PEACOCK color name database you make this call.

Returns:
 Nothing


Also See the Following

cbnAddUserColor()


cbnColorExists

Also see

BOOL cbnColorExists(LPSTR colorName)

Parameters:
 LPSTR colorName : This is the name of the color to check the existence of.

Description:
 To check if a color name exists in the PEACOCK color name database you make this call.  This call will check both the [rgbcolors] and [usercolors] sections of the database.

Returns:
 If the color name is found returns True (1).
If the color name is not found return False (0).


Also See the Following

cbnUserColorExists()


cbnUserColorExists

Also see

BOOL cbnUserColorExists(LPSTR colorName)

Parameters:
 LPSTR colorName : This is the name of the color to check the existence of.

Description:
 To check if a color name exists in the PEACOCK color name database you make this call.  This call will check only the [usercolors] sections of the database.

Returns:
 If the color name is found returns True (1).
If the color name is not found return False (0).


Also See the Following

cbnColorExists(colorName)


cbnGetColor

Also see

LONG cbnGetColor(LPSTR colorName,long defaultValue)

Parameters:
 LPSTR colorName : This is the name of the color name to get the RBG value for.
LONG defaultValue : This is the value returned if the color name is not found.

Description:
 This routine attempts to return the RGB value of the color name given it.  This routine checks both the [rgbcolors] and [usercolors] sections of the PEACOCK color name database.

Returns:
 If the color name is found returns RGB value.
If the color name is not found return defaultValue.


Also See the Following

cbnGetUserColor()


cbnGetUserColor

Also see

LONG cbnGetUserColor(LPSTR colorName, long defaultValue)

Parameters:
 LPSTR colorName : This is the name of the color name to get the RBG value for.
LONG defaultValue : This is the value returned if the color name is not found.

Description:
 This routine attempts to return the RGB value of the color name given it.  This routine checks only the [usercolors] sections of the PEACOCK color name database.

Returns:
 If the color name is found returns RGB value.
If the color name is not found return defaultValue.


Also See the Following

cbnGetColor()


cbnGetColorList

Also see

VOID cbnGetColorList(LPSTR list, int listLength)

Parameters:
 LPSTR list : The list space to write the color names into.
int listLength : The amount of space available in list to hold names.

Description:
 This routine will return a list of all the color names supported by the PEACOCK color name database.  This routine returns only those names in the [rgbcolors] section of the database.  The format for the return is as follows.

The names are written into the list buffer and terminated with a 0 byte.  The final name is terminated by two 0 bytes. So if there are 3 name red,green,pink the return list looks like
red0green0pink00

Returns:
 Nothing.


Also See the Following

cbnGetUserColorList()


cbnGetUserColorList

Also see

VOID cbnGetUserColor(LPSTR list, int listLength)

Parameters:
 LPSTR list : The list space to write the color names into.
int listLength : The amount of space available in list to hold names.

Description:
 This routine will return a list of all the color names supported by the PEACOCK color name database.  This routine returns only those names in the [usercolors] section of the database.  The format for the return is as follows.

The names are written into the list buffer and terminated with a 0 byte.  The final name is terminated by two 0 bytes. So if there are 3 name red,green,pink the return list looks like
red0green0pink00

Returns:
 Nothing.


Also See the Following

cbnGetColorList()


Peacock Visual Basic
PEACOCK Visual Basic Interface

PEACOCK supplies the file PEACOCK.BAS which contains the needed declare statements to use PEACOCK for within VB.

In PEACOCK.BAS you will find a number of declare statements and two constants.  These constants are needed when checking the functions that return a BOOL value.  In VB True = 0 and False = -1.  In C True = 1 and False = 0. This really does not matter, just remember that when checking functions like cbnColorExists you do something like the following.

If cbnColorExists("SteelBlue") = CBN_COLOR_EXISTS Then
' yep we found it
End If

To use PEACOCK with VB simply include the PEACOCK.BAS file in you project and use the DLL functions as you please.


PEACOCK Installation

To install PEACOCK on your system you need to do the following.

Put PEACOCK.INI in your Windows directory
Put PEACOCK.DLL in your Windows directory
Put PEACOCK.BAS in an easy to access location (if your into VB)
Put PEACOCKV.VBX in your Windows directory
Put PEACOCKV.BAS in an easy to access location
Put PEACOCK.HLP in your Windows directory

Note that the above procedure installs all of the PEACOCK components.  Since PEACOCK has a number of configurations all components are not needed for all uses.  If you only need the DLL you can skip the PEACOCKV.* files.  If you only need the VBX you can skip PEACOCK.DLL and PEACOCK.BAS. All configurations need the PEACOCK.INI file.

OK your ready to rock and roll.  I would suggest that first to try firing up the SAMPLDLL or SAMPLVBX  VB programs which are shipped with PEACOCK.  Check it out I think your going to dig it.


PEACOCK Registration

PEACOCK is supplied as shareware.  There are no limitations on it in any way.  You have the real thing!

To register PEACOCK

Send $20.00 + $3.00 Shipping/Handling to

Maplerow Brothers Software
2161 Fawnwood Dr S.E.
Kentwood, Mi 49508

Make all checks payable to Maplerow Brothers Software.

Or:
You can use the Shareware Registration Forum on Compuserve:
To do the on CIS do the following
Go SWREG
Register the PEACOCK product by searching for PEACOCK
or using ID# 3634

Registered users of PEACOCK have the right to redistribute the PEACOCK.INI color name database file with their applications.

By the way if you come up with some real neat color names and values send them along to us.  We will be happy to take a look and add the best to the predefined color name database.

Thanks for using PEACOCK!